Computer Programming/Transcript
Transcript Text reads: The Mysteries of Life with Tim and Moby It is dawn. Moby is standing in the dim kitchen. There is the sound of a door closing and footsteps approaching. Tim enters the kitchen and turns on the light. He is groggy. He is startled when he sees Moby, and he awakens fully. TIM: Have you been standing here all night? MOBY: Beep. TIM: Hmmm. Tim walks to Moby and opens the robot's chest. There is a monitor inside with the message "Runtime Error". TIM: Uh-oh. Were you dividing by zero again? MOBY: Beep. Tim reads from a typed letter. TIM: Dear Tim and Moby, what is computer programming? Thanks, Amy. You picked a good time to ask. Moby zapped his operations chip, and he can't seem to do anything. Right, buddy? Tim places his hand on Moby's shoulder. MOBY: Beep. Moby looks angry. TIM: Don't worry. I've got you covered. We'll just switch you over to voice command. Tim crouches in front of Moby and presses some buttons on the robot's chest. TIM: There. Now I can program you until your replacement chip arrives. Moby's shoulder opens, revealing a remote control device labeled "Moby Voice Command Remote Control." MOBY: Beep. TIM: I know, I know. Your brain is no ordinary computer. But it does have some things in common with the ones people use. An image of Moby's head is surrounded by images of a desktop computer, a laptop, a cell phone, and a tablet. TIM: Computers can do all sorts of amazing things, from navigating the Internet to piloting an airplane. Side-by-side animations show a cursor clicking on an Internet search result and a pilot drinking coffee while the autopilot system guides the plane. TIM: But they can't do anything at all without a set of instructions. An animation of a desktop computer shows the programming language C++ by the processor. TIM: That's all a computer program is, a series of steps that a computer can follow. The C++ sign expands to show lines of computer code. The sign disappears into the processing unit, and Moby's face appears on the desktop computer's monitor. MOBY: Beep. TIM: And somebody has to write those steps. MOBY: Beep. TIM: Unlike you, computers can't really understand English. So programmers have to write their instructions in special languages. That's called "coding," and the lines of instructions are known as "code." MOBY: Beep. Images show four different computer programming codes. TIM: There are literally hundreds of different languages. An animation shows the computer programming languages "Python," "XBase plus plus," "AspectJ," "C plus plus," "Java," and "Limbo." TIM: Thankfully, you don't need to know any of them to understand some programming basics. Just follow along as I code Moby. Tim gestures toward the kitchen counter and speaks into Moby's remote. TIM: OK, Moby. Walk to the counter. Moby attempts to walk, but his feet slip out from beneath him. He hits the kitchen floor. TIM: All right, sorry about that. I have to remember that programs need to be really specific. Tim puts Moby's head back on, and Moby stands beside him again. TIM: They have to be step-by-step, ordered instructions, an algorithm. A vertical flowchart shows these steps of an algorithm: Start. Read a,b. C=a+b. Write c. End. TIM: That's why so many programming tools automatically number your lines of code. An image shows numbered lines of code. TIM: Let's try it. Moby, first lift your right foot. Then, move it ahead of your left foot. Then, put it down. Tim speaks into Moby's remote. His instructions appear on Moby's chest monitor in a numbered sequence. The instructions move to the corner of the screen. Moby is shown in profile, taking a step following the numbered sequence. TIM: Great. Let's call those three lines "Step Right" and save it as a function. That's like a mini-program we can call on whenever we want. An animation of Moby's chest monitor shows the sequence for the function titled "Step Right.". TIM: Now, let's make an identical step function for the left foot. The text on Moby's chest monitor changes to "Step Left: Left foot up, left foot forward, left foot down." TIM: Moby, step left. Then step right. The animation of Moby's chest monitor appears in the corner of the screen. Its text changes to 1. Step Left; 2. Step right. Moby is shown in profile. He takes steps accordingly. TIM: Now, repeat lines 1 and 2 over and over. The image of Moby's monitor disappears, and Moby walks across the kitchen floor. There is a crash, and pots and pans bounce onto the screen. TIM: Repeating a section of code like this is called a loop, and it's something you can do in any programming language. Moby continues to walk around the kitchen as Tim tends to the remote control. TIM: Moby, stop. Then walk back here. Then stop. Moby follows Tim's instructions. TIM: You've just been programmed. Lift your arms in triumph. MOBY:Beep. Moby lifts his arms. TIM: Yeah, it is sort of like making a recipe. Instead of telling a computer what to do, you're telling it how to do it. An animation shows a computer monitor with a face and a chef's hat. It has arms and is holding cooking utensils. TIM: Speaking of recipes, how about making a peanut butter sandwich for lunch? Tim and Moby are standing at the kitchen counter. Tim is holding a loaf of bread in one hand and a jar of peanut butter in the other. There is a cutting board and a knife in front of Moby. TIM: Moby, first put peanut butter on one slice of bread. Then use the knife to spread it around. Moby's monitor shows the steps Tim mentions. Moby places the jar of peanut butter on its side, on top of one slice of bread. Then he rubs the knife on the side of the jar. TIM: OK. Keep it together. Programmers have to be patient. You have to keep refining, or iterating, your code until it works the way you want it to. If there's a mistake, or bug, you have to find out where it is and fix it. Binary code, made up of 0's and 1's, fills the screen. A patch of red computer code that is not 0's and 1's is called out as a bug. TIM: Moby, first open the peanut butter jar. Then, use the knife to scoop out some peanut butter. Then, spread it on a slice of bread. And finally, put another slice on top. Moby's chest monitor displays Tim's commands as numbered steps. MOBY: Beep. Moby smashes the jar of peanut butter with his fist. He scoops and spreads peanut butter and glass onto a slice of bread. Then he places the other slice on top. He tries to hand the sandwich to Tim. TIM: That's closer, but I think I'll just get lunch at school. Hey, that reminds me. I'm late. A ticking clock passes from one side of the screen to the other. Then Tim and Moby are walking down the hall at school. The bell rings. TIM: Quick, Moby. Moby is standing in a classroom doorway. Tim is seated next to an empty desk, whispering and pointing to the empty seat. TIM: First, walk to a seat. Then, sit down in it. Tim speaks instructions into Moby's remote. An animation of Moby's chest monitor displays the instructions. MOBY: Beep. Moby walks to the nearest desk, which is occupied. Moby sits in the student's lap. TIM: I can't take you anywhere. Tim hides his face in his hands. TIM: Here, try this. First, check if the closest seat is occupied. If no, then sit. If yes, then move on to the next seat and repeat. Step-by-step images show Moby following Tim's instructions. MOBY: Beep. Moby follows the instructions Tim gave and sits at the empty desk next to Tim. TIM: Yup, and we got to another big part of coding: conditional statements. That's when the program looks at an unknown value, or variable, and does different things depending on what it is. An image shows an empty chair with a question mark on it. TIM: In this case, the variable was whether the seat was empty. The empty chair turns into a school chair. Two other chairs appear on either side of the first one. A student is seated in one of the chairs. TIM: Moby looked at one desk, judging its condition as occupied or empty. Based on what he saw, he moved on to the next desk or sat down. A series of images shows Moby going through the process that Tim describes. TIM: In other words, he took inputs and used them to generate outputs. The image of the chair with a question mark over it is labeled "Variable/Input;" the images showing an occupied and empty chair is labeled "Condition;" The images showing Moby moving to the next seat or sitting down in an empty chair is labeled "Output." MOBY: Beep. TIM: Right. The computers most of us use don't have fancy eye sensors like you do. Instead, they have input devices like keyboards, mice, and touchscreens. Images show the input devices Tim mentions. TIM: The inputs are the things you type and the places you click or tap, and the output is how the computer processes your input. An animation shows someone using a touchscreen in the ways Tim mentions. MOBY: Beep. TIM: You need a program to what, now? Moby leans over and whispers a beep into Tim's ear. TIM: Oh, um. Miss Linch, can I get a bathroom pass? Moby smiles shyly as Tim calls to his teacher. Category:BrainPOP Transcripts